import { createApp } from "vue";
import App from "./App.vue";

import jmash, {
  store,
  directive,
  useUserStore,
  getQueryParams,
  i18n,
  updateViteMetaEnv,
  axiosConfig,
  defaultSettings,
} from "jmash-core";

/* 默认配置 */
import logo from "./assets/logo.png";
defaultSettings.title = "标准RBAC系统";
defaultSettings.logo = logo;

/* 环境变量 */
const viteMetaEnv: ImportMetaEnv = import.meta.env;
const metaEnv = updateViteMetaEnv(viteMetaEnv);
axiosConfig(metaEnv);

import "element-plus/dist/index.css";
import "jmash-core/dist/style.css";
import "jmash-dict/dist/style.css";
import "jmash-rbac/dist/style.css";
import "jmash-jobs/dist/style.css";
import "jmash-sms/dist/style.css";

import "@/permission";

const app = createApp(App);
// Query参数
const queryParams = getQueryParams();
if (queryParams.tenant) {
  useUserStore().user.tenant = queryParams.tenant;
} else {
  useUserStore().user.tenant = "rbac";
}

import dict from "jmash-dict";
import rbac from "jmash-rbac";
import jobs from "jmash-jobs";
import sms from "jmash-sms";
import region from "jmash-region";

import router from "./router/index";

app
  .use(jmash)
  .use(dict)
  .use(rbac)
  .use(jobs)
  .use(sms)
  .use(region)
  .use(directive)
  .use(store)
  .use(router)
  .use(i18n)
  .mount("#app");
